<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>border效果</title>
    <style>
        body,
        html {
            width: 100%;
            height: 100%;
            display: flex;
        }

        div {
            position: relative;
            margin: auto;
            width: 120px;
            line-height: 64px;
            text-align: center;
            color: #fff;
            font-size: 20px;
            border: 2px solid gold;
            border-radius: 10px;
            background: gold;
            transition: all .3s;
            cursor: pointer;

        }


        div:hover {
            filter: contrast(1.1);
        }

        div:active {
            filter: contrast(0.9);
        }

        div::before,
        div::after {
            content: "";
            position: absolute;
            top: -10px;
            left: -10px;
            right: -10px;
            bottom: -10px;
            border: 2px solid gold;
            transition: all .5s;
            animation: clippath 3s infinite linear;
            border-radius: 10px;
        }

        div::after {
            /*after延迟1.5s出发，可以做出before 和after相互追逐的动画*/
            animation: clippath 3s infinite -1.5s linear;
        }

        @keyframes clippath {

            0%,
            100% {
                clip-path: inset(0 0 98% 0);
            }

            25% {
                clip-path: inset(0 98% 0 0);
            }

            50% {
                clip-path: inset(98% 0 0 0);
            }

            75% {
                clip-path: inset(0 0 0 98%);
            }
        }

        .bg::before {
            background: rgba(255, 215, 0, .5);
        }
    </style>
</head>

<body>
    <div>Hello</div>
</body>

</html>